package org.example.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.example.pojo.User;

/**
* @author LENOVO
* @description 针对表【UserController(用户表单)】的数据库操作Mapper
* @createDate 2024-03-28 20:05:30
* @Entity org.example.pojo.UserController
*/

@Mapper
public interface UserMapper {

    int deleteByPrimaryKey(Long id);

    int insert(User record);

    int insertSelective(User record);

    User selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(User record);

    int updateByPrimaryKey(User record);

    @Select("select * from user where username=#{username}")
    User findByUsername(String username);
    
    @Insert("insert into user(username, password, email, nickname, create_time, update_time)" +
            " values(#{username},#{md5password},#{email},#{nickname}, now(),now())")
    void SignIn(String username, String md5password, String email, String nickname);

    @Update("update user set nickname=#{nickname} where id=#{id}")
    void addCoupleName(String nickname, Object id);

    @Update("update user set user_pic=#{url} where id=#{id}")
    void upload(String url, Object id);

    @Select("select * from user where nickname=#{nickname}")
    User findByNickname(String nickname);

    @Select("select * from user where id=#{id}")
    User findByUser(Integer id);

    @Update("update user set password=#{Md5rePwd} where id=#{id}")
    void updatePwd(Integer id, String Md5rePwd);

    @Select("select * from user where email=#{email}")
    String findByEmail(String email);

    @Update("update user set password=#{Md5rePwd} where email=#{email}")
    void updatePwdEmail(String email, String Md5rePwd);
}
